function equaliz(fileetalon,filein,fileout)

x=int16(wavread2(fileetalon));
[xx,Fs]=wavread2(fileetalon,1);
y=int16(wavread2(filein));

etalon=double(x(1:1024));

k=1;
minind=k;
mindif=erpow(double(y(k:(k+1023))),etalon);
maxind=k;
maxdif=mindif;

for k=2:20000,
 dif=erpow(double(y(k:(k+1023))),etalon);

 if dif<mindif
  mindif=dif;
  minind=k;
 end 

 if dif>maxdif
  maxdif=dif;
  maxind=k;
 end 
 
end 
if minind~=1
 disp(['Ëèøíèõ îòñ÷åòîâ â íà÷àëå ' num2str(minind-1)])
end
y2=y(minind:end);

if length(y2)>length(x)
 disp(['Ëèøíèõ îòñ÷åòîâ â êîíöå ' num2str(length(y2)-length(x))])
 y2=y2(1:length(x));
end
if length(y2)<length(x)
 disp(['Íå õâàòàëî ' num2str(length(x)-length(y2)) ' îòñ÷åòîâ â êîíöå'])
 y2(length(y2)+1:length(x))=0;
end

wavwrite2(double(y2),Fs,fileout)
